package algorithm.tree.bst;

import algorithm.tree.PrintTree;

import java.util.Random;

/**
 * 遍历二叉树
 */
public class TreeBianLi {

  public static void main(String[] args) {

    //测试插入
    BST bst = new BST();
    //声明
    Random random = new Random();
    for (int i = 0; i < 10; i++) {
      int i1 = random.nextInt(100);
      Entity entity = new Entity(i1, "2");
      bst.put(entity);
    }
    PrintTree.displayTree(bst.root);
    dis(bst.root);
  }

  /**
   * 中序遍历
   *
   * @param node
   */
  public static void dis(TreeNode node) {
    if (node == null) {
      return;
    }
    dis(node.left);
    System.out.println(node.value);
    dis(node.right);
  }



}
